<?php include '../public/header.php' ?>
<?php include '../public/header_public.php' ?>
<body class="laytp-container">
<div style="height: 45px"></div>
<div id="opt_nav">
</div>
<div id="dialog">
    <div class="page-title" id="page-title">
        <div class="page-title-con">
            <span class="title">施工合同</span>
            <div class="move_title"></div>
            <div class="page-title-opt-list">
                <span id="page-close" class="page-close" onclick="layer_close()">×</span>
            </div>
        </div>
    </div>
</div>

<div class="layui-card" id="search-form">
    <div class="layui-card-body">
        <form class="layui-form" id="TableSearchFormId" lay-filter="TableSearchForm" onkeydown="keyTableSearch('TableSearchForm', 'datalist')">
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">项目名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="enginname" id="enginname" placeholder="请输入" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">项目编号</label>
                        <div class="layui-input-block">
                            <input type="text" name="enginnumber" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">项目所属单位</label>
                        <div class="layui-input-block">
                            <div id="chanid" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">项目属性：</label>
                        <div class="layui-input-block">
                            <select id="business" name="business" lay-filter="business">
                                <option value="">请选择</option>
                                <option value="1">自营</option>
                                <option value="2">联营</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">合同名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="name" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">合同编号</label>
                        <div class="layui-input-block">
                            <input type="text" name="number" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>

                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">合同类型</label>
                        <div class="layui-input-block">
                            <div id="shihetype" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">合同年份：</label>
                        <div class="layui-input-block">
                            <select id="year" name="year" lay-filter="year">
                                <option value="">请选择</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">发包方(甲方)</label>
                        <div class="layui-input-block">
                            <input type="text" name="faer" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">承包方(乙方)</label>
                        <div class="layui-input-block">
                            <div id="chenger" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">合同状态：</label>
                        <div class="layui-input-block">
                            <select id="state" name="state" lay-filter="state">
                                <option value="">请选择</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">质保金到期日期</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="zhidt" placeholder="请输入" autocomplete="off" class="layui-input bdate_sea_range_ymd">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">审核状态：</label>
                        <div class="layui-input-block">
                            <select id="status" name="status" lay-filter="status">
                                <option value="">请选择</option>
                                <option value="1">流程（审批通过）</option>
                                <option value="0">流程（审批中）</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <div class="layui-form-item search-div">
                            <div class="layui-form-item layui-inline">
                                <button class="laytp-btn laytp-btn-md laytp-btn-primary" id="TableSearchButton" type="button"><i class="layui-icon layui-icon-search"></i>查询</button>
                                <div id="search_open" onclick="toggle_search()">
                                    <i class="layui-icon layui-icon-down"></i>展开
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="layui-card" id="table-card">
    <div class="layui-card-body">
        <div class="layui-row">
            <div class="layui-col-md12" id="table_list">
                <div class="layui-card-body">
                    <table id="datalist" lay-filter="datalist"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="test-dropdown-toolbar-barDemo">
    <div class="tab-list-authbut">
        <a href="javascript:;" class="bar_opt" onclick="auth_but_func_show('查看','{{d.LAY_TABLE_INDEX}}')">查看</a>
    </div>
</script>
<script type="text/html" id="toolbarDemo">
    <div class = "layui-btn-container">
    </div>
</script>

<script>
    var param_chanid = getQueryVariable('chanid') || 0;
    var param_channame = decodeURI(getQueryVariable('channame') || '') || '';

    var param_enginname = decodeURI(getQueryVariable('enginname') || '') || '';
    if(param_enginname){
        $("#enginname").val(param_enginname);
        $("#enginname").prop('disabled', true);
        $("#enginname").addClass('disabled');
    }

    var param_status = decodeURI(getQueryVariable('status') || 1);
    $("#status").val(param_status);


    var currTabData;
    layui.use(["laytp",'laypage','table','dropdown','form','soulTable'], function () {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable;


        $('#TableSearchReset').click(function () {
            $('.xmselect_div>xm-select').find('.xm-label-block').css('display','none');
            $('.xmselect_div').append('<div class="xmselect_title">请选择</div>');
            searchTableFunc(form, table)
        });

        setSouTableExport('施工合同');
        var mytable = table.render({
            elem: "#datalist",id: "datalist"
            ,url: facade.url(ask_contract_shi_list),where: {enginname:param_enginname, status:param_status, chanid:param_chanid}, page: true
            ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: TabInit.toolbar, overflow: TabInit.overflow
            ,defaultToolbar: TabInit.defaultToolbar,filter: TabInit.filter
            ,request: TabInit.request,response: TabInit.response,contextmenu:get_table_contextmenu(soulTable)
            ,text: TabInit.text,totalRow: true
            ,parseData: function (res) {

                if(param_chanid > 0){
                    $("#chanid .xmselect_title").html(param_channame);
                }else{
                    xmselect_dan('chanid', res.data.chanid, res.data.is_chanid, function (res) {
                        setTimeout(function () {
                            searchTableFunc(form, table);
                        },100)
                    })
                }


                xmselect_dan('shihetype', res.data.shihetype, res.data.is_shihetype, function (res) {
                    setTimeout(function () {
                        searchTableFunc(form, table);
                    },100)
                })

                xmselect_dan('chenger', res.data.chenger, res.data.is_chenger, function (res) {
                    setTimeout(function () {
                        searchTableFunc(form, table);
                    },100)
                })


                var year_str = '<option value="">请选择</option>';
                var year = res.data.year;
                for (var key in year){
                    if(res.data.is_year == key){
                        year_str += '<option value="'+year[key]+'" selected>'+year[key]+'</option>';
                    }else {
                        year_str += '<option value="'+year[key]+'">'+year[key]+'</option>';
                    }

                }
                $("#year").html(year_str);


                var state_str = '<option value="">请选择</option>';
                var state = res.data.state;
                for (var key in state){
                    if(res.data.is_state == key){
                        state_str += '<option value="'+key+'" selected>'+state[key]+'</option>';
                    }else {
                        state_str += '<option value="'+key+'">'+state[key]+'</option>';
                    }

                }
                $("#state").html(state_str);

                render_from();

                if(param_chanid > 0){
                    $("#chanid").html('<div class="xmselect_title">'+param_channame+'</div>');
                }


                return {
                    "code": res.code,
                    "msg": res.message,
                    "count": res.data.data.total,
                    "data": res.data.data.data
                };
            }
            , cols: [[
                {type: "checkbox", fixed: 'left'}
                ,{type:'numbers',title:'序号',totalRowText: '合计',fixed:'left'}
                ,list_bill_cols_str
                ,{field: 'enginname', title: '项目名称'}
                ,{field: 'business_name', title: '项目属性'}
                ,{field: 'neiname', title: '内包协议'}
                ,{field: 'name', title: '合同名称'}
                ,{field: 'number', title: '合同编号'}
                ,{field: 'shihetype', title: '合同类型'}
                ,{field: 'year', title: '合同年份'}
                ,{field: 'faer', title: '(发包方)甲方'}
                ,{field: 'chenger_name', title: '承包方(乙方)'}
                ,{field: 'money', title: '合同金额(元)',totalRow: true}
                ,{field: 'shimoney', title: '变更后金额(元)',totalRow: true}
                ,{field: 'rate', title: '税率(%)'}
                ,{field: 'startdt', title: '合同开工日期'}
                ,{field: 'enddt', title: '合同竣工日期'}
                ,{field: 'duration', title: '工期'}
                ,{field: 'zhilevel', title: '质量验收等级'}
                ,{field: 'state_name', title: '合同状态'}
                ,{field: 'fauser', title: '甲方联系人'}
                ,{field: 'myer', title: '我方签订人'}
                ,{field: 'fatel', title: '甲方联系方式'}
                ,{field: 'qiandt', title: '签订日期'}
                ,{field: 'zhirate', title: '质保金比例(%)'}
                ,{field: 'zhifee', title: '质保金金额(元)'}
                ,{field: 'zhinum', title: '质保期(天)'}
                ,{field: 'zhidt', title: '质保金到期日期'}
                ,{fixed: 'right', title:'操作', toolbar: '#test-dropdown-toolbar-barDemo',align:'center',width:200}
            ]]
            , done: function (res) {
                soulTable.render(this);
                currTabData = res.data;
            }
        });


        listTableSearch(form, table);
    });


    function auth_but_func_show(buttitle, index){
        var trData = currTabData[index];
        openPage('show.php?id='+trData.id);
    }


</script>
</body>
</html>
